	@include("user.head")

	<div id="content_person">
		<div class="row">
			<div class="col-xs-3">
				@include('user.uc.navigation')
			</div>
			<div class="col-xs-9">
				<div class="panel panel-default">
				  <div class="panel-heading">
				    <h3 class="panel-title">编辑个人信息</h3>
				  </div>
				  <div class="panel-body">
				  	<div class="form-horizontal">
						<div class="form-group">
							<label for="inputNick" class="col-xs-2 control-label">昵称:</label>
							<div class="col-xs-5">
								<input class="form-control" value="" id="inputNick" placeholder="昵称" type="text">
								<span class="hint">
						        	<i class="fa fa-check-circle"></i> <span class="msg"></span>
						        </span>
							</div>
						</div>
						<div class="form-group">
					      <label class="col-xs-2 control-label">性别:</label>
					      <div class="col-xs-5">
					        <div class="radio">
					          <label>
					            <input type="radio" name="sex" id="" value="1" checked="checked">
					            男
					          </label>
					        </div>
					        <div class="radio">
					          <label>
					            <input type="radio" name="sex" id="" value="0">
					            女
					          </label>
					        </div>
					      </div>
					    </div>
						<div class="form-group">
							<label for="contact" class="col-xs-2 control-label">联系方式:</label>
							<div class="col-xs-5">
								<input class="form-control" value="" id="contact" placeholder="联系方式" type="text">
								<span class="hint">
						        	<i class="fa fa-check-circle"></i> <span class="msg"></span>
						        </span>
							</div>
						</div>
						<div class="form-group">
							<label for="email" class="col-xs-2 control-label">电子邮箱:</label>
							<div class="col-xs-5">
								<input class="form-control" value="" id="email" placeholder="电子邮箱" type="text">
								<span class="hint">
						        	<i class="fa fa-check-circle"></i> <span class="msg"></span>
						        </span>
							</div>
						</div>
						<div class="form-group">
					       <label for="select" class="col-xs-2 control-label">省/市/区:</label>
					       <div class="col-xs-5">
								<div class="col-xs-4 no_padding_left">
									<select class="form-control col-xs-4" id="province">
								   <option value="">请选择</option>
								   @foreach ($province as $value)
								   <option value="<%$value['area_id']%>"><%$value["area_name"]%></option>
								   @endforeach
								 </select>
								</div>
								<div class="col-xs-4 no_padding_left">
									<select class="form-control col-xs-4" id="city">
								   <option value="">请选择</option>
								   @foreach($city as $value)
								   <option value="<%$value['area_id']%>"><%$value['area_name']%></option>
								   @endforeach

								 </select>
								</div>
								<div class="col-xs-4 no_padding_left">
									<select class="form-control col-xs-4" id="area">
								       <option value="">请选择</option>
								       @foreach($area as $value)
								       <option value="<%$value['area_id']%>"><%$value['area_name']%></option>
								       @endforeach
								    </select>
								</div>
								<div class="col-xs-12 no_padding_left">
									<span class="hint">
							        	<i class="fa fa-check-circle"></i> <span class="msg"></span>
							        </span>
								</div>
					       </div>
					     </div>
					     <div class="form-group">
							<label for="address" class="col-xs-2 control-label">详细地址:</label>
							<div class="col-xs-5">
								<input class="form-control" value="" id="address" placeholder="详细地址" type="text">
								<span class="hint">
						        	<i class="fa fa-check-circle"></i> <span class="msg"></span>
						        </span>
							</div>
						</div>
						<div class="form-group">
					      <div class="col-xs-12 text-center">
					        <button type="botton" id="saveBtn" class="btn btn-primary">保存修改</button>
					      </div>
					    </div>
					</div>
				  </div>
				</div>
			</div>
		</div>
	</div>
	<!-- 公共底部 -->
	@include("user.footer")
	@include("user.common")
	<!-- 公共底部 -->
</body>


<script type="text/javascript">

$.get("edit_profile/list", function(data){
	if(data.success){
		var data = data.data;
		$("#inputNick").val(data.nickname);
		$("input[type=radio][value='" + data.sex + "']").attr("checked", "checked");
		$("#contact").val(data.contact_way);
		$("#email").val(data.email);
		$("#address").val(data.address);
		$("#province").val(data.province);
		$("#city").val(data.city);
		$("#area").val(data.area);
	}else{
	}
});


$("#province").change(function(){
	var pid = $(this).val();
	$.get('<% url("uc/address/getarea") %>', {pid : pid}, function(data){
		var str = '<option value="-1">请选择</option>';
		$.each(data.area,function(k, v){
			str += '<option value="'+v.area_id+'">'+v.area_name+'</option>';
		})
		$("#city").html(str);
		$("#area").html('<option value="-1">请选择</option>');
	})
})

$("#city").change(function(){
	var pid = $(this).val();
	$.get('<% url("uc/address/getarea") %>', {pid : pid}, function(data){
		var str = '<option value="-1">请选择</option>';
		$.each(data.area,function(k, v){
			str += '<option value="'+v.area_id+'">'+v.area_name+'</option>';
		})
		$("#area").html(str);
	})
});


$("#saveBtn").on("click", function(){
	var nickname = $("#inputNick").val();
	var sex = $("input[name='sex']:checked").val();
	var contact = $("#contact").val();
	var email = $("#email").val();
	var province = $("#province").val();
	var city = $("#city").val();
	var area = $("#area").val();
	var addr = $("#address").val();

	var param = {
		"nickname": nickname,
		"sex": sex,
		"contact_way": contact,
		"email": email,
		"province": province,
		"city": city,
		"area": area,
		"address": addr
	};
	$.post("edit_profile/update", param, function(data){
		if(data.success){
			success("", "修改成功!");
			setTimeout(function(){
				window.location.href="profile";
			},2000)
		}else{
			error("", data.msg);
		}
	});
});
</script>
</html>